package com.hetao.assist.service.mq;


import com.hetao.assist.model.Stock;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

@Component
public class FanoutSmsConsumer {

    Logger logger = LoggerFactory.getLogger(getClass());

    @RabbitListener(queues = "#{fanoutSmsQueue.name}")
    @RabbitHandler
    public void process(String message) {
        logger.info("fanout_sms_queue sms: {}", message);

    }


    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "fanout_sms_queue2", ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true", exclusive = "false"), exchange = @Exchange(value = "fanoutExchange1", type = ExchangeTypes.FANOUT, ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true"), key = "friendInfo", ignoreDeclarationExceptions = "true"))
    public void process2(String message) {
        logger.info("fanout_sms_queue22 sms: {}", message);

    }

    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "friend-info-queue1", ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true", exclusive = "false"), exchange = @Exchange(value = "test-exchange", type = ExchangeTypes.DIRECT, ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true"), key = "friendInfo", ignoreDeclarationExceptions = "true"), containerFactory = "myFactory")
    public void process3(Stock message) {
        logger.info("fanout_sms_queue33 sms: {}", message.getCode());

    }

    @RabbitListener(bindings = @QueueBinding(value = @Queue(value = "friend-info-queue1", ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true", exclusive = "false"), exchange = @Exchange(value = "test-exchange", type = ExchangeTypes.DIRECT, ignoreDeclarationExceptions = "true", autoDelete = "false", durable = "true"), key = "friendInfo", ignoreDeclarationExceptions = "true"), containerFactory = "myFactory")
    public void process4(Stock message) {
        logger.info("fanout_sms_queue44 sms: {}", message);

    }
}
